home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / update~4.z / update~4 / lib_stdio_fseek.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  735 b   |  39 lines

  1. /*                f s e e k
  2.  *
  3.  * Set the position of a stream. The new position is at the signed
  4.  * distance offset bytes from either the beginning, current position
  5.  * of end of the file. Any effects of ungetc() are undone.
  6.  *
  7.  * The function returns EOF for improper seeks, otherwise zero.
  8.  *
  9.  * Patchlevel 1.0
  10.  *
  11.  * Edit History:
  12.  */
  13.  
  14. #include "stdiolib.h"
  15.  
  16. /*LINTLIBRARY*/
  17.  
  18. int fseek(fp, offset, ptr)
  19.  
  20. FILE *fp;                /* stream */
  21. long offset;                /* offset */
  22. int ptr;                /* reference */
  23.  
  24. {
  25.   long lseek();                /* seek on file */
  26.  
  27.   if (fflush(fp) || lseek(fp->_file, offset, ptr) == EOF)
  28.     return EOF;
  29.  
  30.   CLEARFLAG(fp, _IOEOF);
  31.  
  32.   if (TESTFLAG(fp, _IORW)) {
  33.     CLEARFLAG(fp, (_IOREAD | _IOWRITE));
  34.     FLUSHNEXTACCESS(fp);
  35.   }
  36.  
  37.   return 0;
  38. }
  39.